<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>Boost.Hana: boost::hana::optional&lt; T &gt; Struct Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
MathJax.Hub.Config({
    "HTML-CSS": {
        linebreaks: {
            automatic: true,
            width: "75% container"
        }
    }
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<!-- Additional javascript for drawing charts. -->
<script type="text/javascript" src="highcharts.js"></script>
<script type="text/javascript" src="highcharts-data.js"></script>
<script type="text/javascript" src="highcharts-exporting.js"></script>
<script type="text/javascript" src="chart.js"></script>
<script type="text/javascript" src="hana.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Boost.Hana
   &#160;<span id="projectnumber">1.7.1</span>
   </div>
   <div id="projectbrief">Your standard library for metaprogramming</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('structboost_1_1hana_1_1optional.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#related">Synopsis of associated functions</a> &#124;
<a href="#friends">Friends</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="structboost_1_1hana_1_1optional-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">boost::hana::optional&lt; T &gt; Struct Template Reference<div class="ingroups"><a class="el" href="group__group-datatypes.html">Data types</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<div class="textblock"><h3>template&lt;typename ... T&gt;<br />
struct boost::hana::optional&lt; T &gt;</h3>

<p>Optional value whose optional-ness is known at compile-time. </p>
<p>An <code>optional</code> either contains a value (represented as <code>just(x)</code>), or it is empty (represented as <code>nothing</code>). In essence, <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> is pretty much like a <code>boost::optional</code> or the upcoming <code>std::optional</code>, except for the fact that whether a <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> is empty or not is known at compile-time. This can be particularly useful for returning from a function that might fail, but whose reason for failing is not important. Of course, whether the function will fail has to be known at compile-time.</p>
<p>This is really an important difference between <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> and <code>std::optional</code>. Unlike <code>std::optional&lt;T&gt;{}</code> and <code>std::optional&lt;T&gt;{x}</code> who share the same type (<code>std::optional&lt;T&gt;</code>), <code>hana::just(x)</code> and <code>hana::nothing</code> do not share the same type, since the state of the optional has to be known at compile-time. Hence, whether a <code>hana::just</code> or a <code>hana::nothing</code> will be returned from a function has to be known at compile-time for the return type of that function to be computable by the compiler. This makes <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> well suited for static metaprogramming tasks, but very poor for anything dynamic.</p>
<dl class="section note"><dt>Note</dt><dd>When you use a container, remember not to make assumptions about its representation, unless the documentation gives you those guarantees. More details <a class="el" href="index.html#tutorial-containers-types">in the tutorial</a>.</dd></dl>
<h2><a class="anchor" id="autotoc_md295"></a>
Interoperation with &lt;tt&gt;type&lt;/tt&gt;s</h2>
<p>When a <code>just</code> contains an object of type <code>T</code> which is a <code>type</code>, it has a nested <code>::type</code> alias equivalent to <code>T::type</code>. <code>nothing</code>, however, never has a nested <code>::type</code> alias. If <code>t</code> is a <code>type</code>, this allows <code>decltype(just(t))</code> to be seen as a nullary metafunction equivalent to <code>decltype(t)</code>. Along with the <code>sfinae</code> function, this allows <code><a class="el" href="structboost_1_1hana_1_1optional.html" title="Optional value whose optional-ness is known at compile-time.">hana::optional</a></code> to interact seamlessly with SFINAE-friendly metafunctions. Example: </p><div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="traits_8hpp.html">boost/hana/traits.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;utility&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> ...&gt;</div>
<div class="line"><span class="keyword">using</span> void_t = void;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> = <span class="keywordtype">void</span>&gt;</div>
<div class="line"><span class="keyword">struct </span>has_type : std::false_type { };</div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><span class="keyword">struct </span>has_type&lt;T, void_t&lt;typename T::type&gt;&gt;</div>
<div class="line">    : std::true_type</div>
<div class="line">{ };</div>
<div class="line"> </div>
<div class="line"><span class="keyword">auto</span> common_type_impl = hana::sfinae([](<span class="keyword">auto</span> t, <span class="keyword">auto</span> u) -&gt; hana::type&lt;</div>
<div class="line">    decltype(<span class="keyword">true</span> ? hana::traits::declval(t) : hana::traits::declval(u))</div>
<div class="line">&gt; { <span class="keywordflow">return</span> {}; });</div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;</div>
<div class="line"><span class="keyword">using</span> common_type = decltype(common_type_impl(hana::type_c&lt;T&gt;, hana::type_c&lt;U&gt;));</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">  common_type_impl(hana::type_c&lt;int&gt;, hana::type_c&lt;float&gt;)</div>
<div class="line">    ==</div>
<div class="line">  hana::just(hana::type_c&lt;float&gt;)</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line">static_assert(!has_type&lt;common_type&lt;int, int*&gt;&gt;{}, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">static_assert(std::is_same&lt;common_type&lt;int, float&gt;::type, <span class="keywordtype">float</span>&gt;{}, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="aassert_8hpp_html"><div class="ttname"><a href="assert_8hpp.html">assert.hpp</a></div><div class="ttdoc">Defines macros to perform different kinds of assertions.</div></div>
<div class="ttc" id="aequal_8hpp_html"><div class="ttname"><a href="equal_8hpp.html">equal.hpp</a></div><div class="ttdoc">Defines boost::hana::equal.</div></div>
<div class="ttc" id="agroup__group-assertions_html_ga2c5006540936d9f8880e3a39f4fcc035"><div class="ttname"><a href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTANT_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...</div><div class="ttdef"><b>Definition:</b> assert.hpp:239</div></div>
<div class="ttc" id="anamespaceboost_1_1hana_html"><div class="ttname"><a href="namespaceboost_1_1hana.html">boost::hana</a></div><div class="ttdoc">Namespace containing everything in the library.</div><div class="ttdef"><b>Definition:</b> accessors.hpp:20</div></div>
<div class="ttc" id="anot_8hpp_html"><div class="ttname"><a href="not_8hpp.html">not.hpp</a></div><div class="ttdoc">Defines boost::hana::not_.</div></div>
<div class="ttc" id="aoptional_8hpp_html"><div class="ttname"><a href="optional_8hpp.html">optional.hpp</a></div><div class="ttdoc">Defines boost::hana::optional.</div></div>
<div class="ttc" id="atraits_8hpp_html"><div class="ttname"><a href="traits_8hpp.html">traits.hpp</a></div><div class="ttdoc">Defines function-like equivalents to the standard &lt;type_traits&gt;, and also to some utilities like std:...</div></div>
<div class="ttc" id="atype_8hpp_html"><div class="ttname"><a href="type_8hpp.html">type.hpp</a></div><div class="ttdoc">Defines boost::hana::type and related utilities.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md296"></a>
Modeled concepts</h2>
<ol type="1">
<li><code>Comparable</code><br  />
Two <code>optional</code>s are equal if and only if they are both empty or they both contain a value and those values are equal. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::nothing == hana::nothing);</div>
<div class="line">static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>) == hana::just(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>) != hana::just(<span class="charliteral">&#39;y&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::just(<span class="charliteral">&#39;x&#39;</span>) != hana::nothing);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="anot__equal_8hpp_html"><div class="ttname"><a href="not__equal_8hpp.html">not_equal.hpp</a></div><div class="ttdoc">Defines boost::hana::not_equal.</div></div>
</div><!-- fragment --></li>
<li><code>Orderable</code><br  />
Optional values can be ordered by considering the value they are holding, if any. To handle the case of an empty optional value, we arbitrarily set <code>nothing</code> as being less than any other <code>just</code>. Hence, <div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x) &lt; <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(y) <span class="keywordflow">if</span> and only <span class="keywordflow">if</span> x &lt; y</div>
<div class="line"><a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a> &lt; <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(anything)</div>
<div class="ttc" id="astructboost_1_1hana_1_1optional_html_a0c315287473aa87fe5ccd9d8a1c10186"><div class="ttname"><a href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">boost::hana::optional::nothing</a></div><div class="ttdeci">constexpr optional nothing</div><div class="ttdoc">An empty optional value.</div><div class="ttdef"><b>Definition:</b> optional.hpp:343</div></div>
<div class="ttc" id="astructboost_1_1hana_1_1optional_html_a8ad818d6df7379b0adefa45d2ac844d0"><div class="ttname"><a href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">boost::hana::optional::just</a></div><div class="ttdeci">constexpr auto just</div><div class="ttdoc">Create an optional value containing x.</div><div class="ttdef"><b>Definition:</b> optional.hpp:323</div></div>
</div><!-- fragment --> Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="greater_8hpp.html">boost/hana/greater.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="less_8hpp.html">boost/hana/less.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::nothing &lt; hana::just(3));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::just(0) &gt; hana::nothing);</div>
<div class="line">static_assert(hana::just(1) &lt; hana::just(3), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">static_assert(hana::just(3) &gt; hana::just(2), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="agreater_8hpp_html"><div class="ttname"><a href="greater_8hpp.html">greater.hpp</a></div><div class="ttdoc">Defines boost::hana::greater.</div></div>
<div class="ttc" id="aless_8hpp_html"><div class="ttname"><a href="less_8hpp.html">less.hpp</a></div><div class="ttdoc">Defines boost::hana::less.</div></div>
</div><!-- fragment --></li>
<li><code>Functor</code><br  />
An optional value can be seen as a list containing either one element (<code>just(x)</code>) or no elements at all (<code>nothing</code>). As such, mapping a function over an optional value is equivalent to applying it to its value if there is one, and to <code>nothing</code> otherwise: <div class="fragment"><div class="line">transform(<a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x), f) == <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f(x))</div>
<div class="line">transform(<a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>, f) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div>
</div><!-- fragment --> Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="placeholder_8hpp.html">boost/hana/functional/placeholder.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="transform_8hpp.html">boost/hana/transform.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::transform(hana::nothing, <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1) == hana::nothing);</div>
<div class="line">static_assert(hana::transform(hana::just(1), <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1) == hana::just(2), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="agroup__group-functional_html_gaefe9fd152cba94be71c2b5b9de689d23"><div class="ttname"><a href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">boost::hana::_</a></div><div class="ttdeci">constexpr unspecified _</div><div class="ttdoc">Create simple functions representing C++ operators inline.</div><div class="ttdef"><b>Definition:</b> placeholder.hpp:70</div></div>
<div class="ttc" id="aplaceholder_8hpp_html"><div class="ttname"><a href="placeholder_8hpp.html">placeholder.hpp</a></div><div class="ttdoc">Defines boost::hana::_.</div></div>
<div class="ttc" id="atransform_8hpp_html"><div class="ttname"><a href="transform_8hpp.html">transform.hpp</a></div><div class="ttdoc">Defines boost::hana::transform.</div></div>
</div><!-- fragment --></li>
<li><code>Applicative</code><br  />
First, a value can be made optional with <code>lift&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;</code>, which is equivalent to <code>just</code>. Second, one can feed an optional value to an optional function with <code>ap</code>, which will return <code>just(f(x))</code> if there is both a function <em>and</em> a value, and <code>nothing</code> otherwise: <div class="fragment"><div class="line">ap(<a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f), <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x)) == <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f(x))</div>
<div class="line">ap(<a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>, <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x)) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div>
<div class="line">ap(<a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(f), <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div>
<div class="line">ap(<a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>, <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>) == <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a></div>
</div><!-- fragment --> A simple example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ap_8hpp.html">boost/hana/ap.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">constexpr <span class="keywordtype">char</span> next(<span class="keywordtype">char</span> c) { <span class="keywordflow">return</span> c + 1; }</div>
<div class="line"> </div>
<div class="line">static_assert(hana::ap(hana::just(next), hana::just(<span class="charliteral">&#39;x&#39;</span>)) == hana::just(<span class="charliteral">&#39;y&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::ap(hana::nothing, hana::just(<span class="charliteral">&#39;x&#39;</span>)) == hana::nothing);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::ap(hana::just(next), hana::nothing) == hana::nothing);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::ap(hana::nothing, hana::nothing) == hana::nothing);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="aap_8hpp_html"><div class="ttname"><a href="ap_8hpp.html">ap.hpp</a></div><div class="ttdoc">Defines boost::hana::ap.</div></div>
</div><!-- fragment --> A more complex example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="ap_8hpp.html">boost/hana/ap.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="bool_8hpp.html">boost/hana/bool.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="config_8hpp.html">boost/hana/config.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="if_8hpp.html">boost/hana/if.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="lift_8hpp.html">boost/hana/lift.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keywordtype">char</span> op&gt;</div>
<div class="line">constexpr <span class="keyword">auto</span> <span class="keyword">function</span> = hana::nothing;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;&gt;</div>
<div class="line">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> function&lt;&#39;+&#39;&gt; = hana::just([](<span class="keyword">auto</span> x, <span class="keyword">auto</span> y) {</div>
<div class="line">    <span class="keywordflow">return</span> x + y;</div>
<div class="line">});</div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;&gt;</div>
<div class="line">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> <span class="keyword">function</span>&lt;<span class="charliteral">&#39;-&#39;</span>&gt; = hana::just([](<span class="keyword">auto</span> x, <span class="keyword">auto</span> y) {</div>
<div class="line">    <span class="keywordflow">return</span> x - y;</div>
<div class="line">});</div>
<div class="line"> </div>
<div class="line"><span class="comment">// and so on...</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keywordtype">char</span> n&gt;</div>
<div class="line">constexpr <span class="keyword">auto</span> digit = <a class="code" href="group__group-_logical.html#gafd655d2222367131e7a63616e93dd080">hana::if_</a>(hana::bool_c&lt;(n &gt;= <span class="charliteral">&#39;0&#39;</span> &amp;&amp; n &lt;= <span class="charliteral">&#39;9&#39;</span>)&gt;,</div>
<div class="line">    hana::just(<span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(n - 48)),</div>
<div class="line">    hana::nothing</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="keyword">template</span> &lt;<span class="keywordtype">char</span> x, <span class="keywordtype">char</span> op, <span class="keywordtype">char</span> y&gt;</div>
<div class="line">BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> evaluate = hana::ap(function&lt;op&gt;, digit&lt;x&gt;, digit&lt;y&gt;);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(evaluate&lt;&#39;1&#39;, &#39;+&#39;, &#39;2&#39;&gt; == hana::just(1 + 2));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(evaluate&lt;&#39;4&#39;, &#39;-&#39;, &#39;2&#39;&gt; == hana::just(4 - 2));</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;?&#39;, &#39;+&#39;, &#39;2&#39;&gt; == hana::nothing);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;1&#39;, &#39;?&#39;, &#39;2&#39;&gt; == hana::nothing);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;1&#39;, &#39;+&#39;, &#39;?&#39;&gt; == hana::nothing);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(evaluate&lt;&#39;?&#39;, &#39;?&#39;, &#39;?&#39;&gt; == hana::nothing);</div>
<div class="line"> </div>
<div class="line">    static_assert(hana::lift&lt;hana::optional_tag&gt;(123) == hana::just(123), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">}</div>
<div class="ttc" id="abool_8hpp_html"><div class="ttname"><a href="bool_8hpp.html">bool.hpp</a></div><div class="ttdoc">Defines the Logical and Comparable models of boost::hana::integral_constant.</div></div>
<div class="ttc" id="aconfig_8hpp_html"><div class="ttname"><a href="config_8hpp.html">config.hpp</a></div><div class="ttdoc">Defines configuration macros used throughout the library.</div></div>
<div class="ttc" id="agroup__group-_logical_html_gafd655d2222367131e7a63616e93dd080"><div class="ttname"><a href="group__group-_logical.html#gafd655d2222367131e7a63616e93dd080">boost::hana::if_</a></div><div class="ttdeci">constexpr auto if_</div><div class="ttdoc">Conditionally return one of two values based on a condition.</div><div class="ttdef"><b>Definition:</b> if.hpp:41</div></div>
<div class="ttc" id="agroup__group-assertions_html_gac7aafc41e4dcc7d1f1929fb00f010d2a"><div class="ttname"><a href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTEXPR_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTEXPR_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERT...</div><div class="ttdef"><b>Definition:</b> assert.hpp:300</div></div>
<div class="ttc" id="aif_8hpp_html"><div class="ttname"><a href="if_8hpp.html">if.hpp</a></div><div class="ttdoc">Defines boost::hana::if_.</div></div>
<div class="ttc" id="alift_8hpp_html"><div class="ttname"><a href="lift_8hpp.html">lift.hpp</a></div><div class="ttdoc">Defines boost::hana::lift.</div></div>
</div><!-- fragment --></li>
<li><code>Monad</code><br  />
The <code>Monad</code> model makes it easy to compose actions that might fail. One can feed an optional value if there is one into a function with <code>chain</code>, which will return <code>nothing</code> if there is no value. Finally, optional-optional values can have their redundant level of optionality removed with <code>flatten</code>. Also note that the <code>|</code> operator can be used in place of the <code>chain</code> function. Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="chain_8hpp.html">boost/hana/chain.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="config_8hpp.html">boost/hana/config.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="flatten_8hpp.html">boost/hana/flatten.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> inc = [](<span class="keyword">auto</span> x) {</div>
<div class="line">        <span class="keywordflow">return</span> hana::just(x + 1);</div>
<div class="line">    };</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(hana::chain(hana::just(1), inc) == hana::just(2));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::chain(hana::nothing, inc) == hana::nothing);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(hana::flatten(hana::just(hana::just(2))) == hana::just(2));</div>
<div class="line">}</div>
<div class="ttc" id="achain_8hpp_html"><div class="ttname"><a href="chain_8hpp.html">chain.hpp</a></div><div class="ttdoc">Defines boost::hana::chain.</div></div>
<div class="ttc" id="aflatten_8hpp_html"><div class="ttname"><a href="flatten_8hpp.html">flatten.hpp</a></div><div class="ttdoc">Defines boost::hana::flatten.</div></div>
</div><!-- fragment --></li>
<li><code>MonadPlus</code><br  />
The <code>MonadPlus</code> model allows choosing the first valid value out of two optional values with <code>concat</code>. If both optional values are <code>nothing</code>s, <code>concat</code> will return <code>nothing</code>. Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="concat_8hpp.html">boost/hana/concat.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="empty_8hpp.html">boost/hana/empty.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">static_assert(<a class="code" href="group__group-_monad_plus.html#ga1946e96c3b4c178c7ae8703724c29c37">hana::concat</a>(hana::nothing, hana::just(<span class="charliteral">&#39;x&#39;</span>)) == hana::just(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_monad_plus.html#ga1946e96c3b4c178c7ae8703724c29c37">hana::concat</a>(hana::nothing, hana::nothing) == hana::nothing);</div>
<div class="line">static_assert(<a class="code" href="group__group-_monad_plus.html#ga1946e96c3b4c178c7ae8703724c29c37">hana::concat</a>(hana::just(<span class="charliteral">&#39;x&#39;</span>), hana::just(<span class="charliteral">&#39;y&#39;</span>)) == hana::just(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::empty&lt;hana::optional_tag&gt;() == hana::nothing);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="aconcat_8hpp_html"><div class="ttname"><a href="concat_8hpp.html">concat.hpp</a></div><div class="ttdoc">Defines boost::hana::concat.</div></div>
<div class="ttc" id="aempty_8hpp_html"><div class="ttname"><a href="empty_8hpp.html">empty.hpp</a></div><div class="ttdoc">Defines boost::hana::empty.</div></div>
<div class="ttc" id="agroup__group-_monad_plus_html_ga1946e96c3b4c178c7ae8703724c29c37"><div class="ttname"><a href="group__group-_monad_plus.html#ga1946e96c3b4c178c7ae8703724c29c37">boost::hana::concat</a></div><div class="ttdeci">constexpr auto concat</div><div class="ttdoc">Combine two monadic structures together.</div><div class="ttdef"><b>Definition:</b> concat.hpp:47</div></div>
</div><!-- fragment --></li>
<li><code>Foldable</code><br  />
Folding an optional value is equivalent to folding a list containing either no elements (for <code>nothing</code>) or <code>x</code> (for <code>just(x)</code>). Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="fold__right_8hpp.html">boost/hana/fold_right.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="plus_8hpp.html">boost/hana/plus.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">static_assert(hana::fold_right(hana::nothing, 1, <a class="code" href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">hana::plus</a>) == 1, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">static_assert(hana::fold_right(hana::just(4), 1, <a class="code" href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">hana::plus</a>) == 5, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="afold__right_8hpp_html"><div class="ttname"><a href="fold__right_8hpp.html">fold_right.hpp</a></div><div class="ttdoc">Defines boost::hana::fold_right.</div></div>
<div class="ttc" id="agroup__group-_monoid_html_gaeb5d4a1e967e319712f9e4791948896c"><div class="ttname"><a href="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">boost::hana::plus</a></div><div class="ttdeci">constexpr auto plus</div><div class="ttdoc">Associative binary operation on a Monoid.</div><div class="ttdef"><b>Definition:</b> plus.hpp:47</div></div>
<div class="ttc" id="aplus_8hpp_html"><div class="ttname"><a href="plus_8hpp.html">plus.hpp</a></div><div class="ttdoc">Defines boost::hana::plus.</div></div>
</div><!-- fragment --></li>
<li><code>Searchable</code><br  />
Searching an optional value is equivalent to searching a list containing <code>x</code> for <code>just(x)</code> and an empty list for <code>nothing</code>. Example: <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="all__of_8hpp.html">boost/hana/all_of.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="find__if_8hpp.html">boost/hana/find_if.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="mod_8hpp.html">boost/hana/mod.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">auto</span> odd = [](<span class="keyword">auto</span> x) {</div>
<div class="line">    <span class="keywordflow">return</span> x % hana::int_c&lt;2&gt; != hana::int_c&lt;0&gt;;</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">hana::find_if</a>(hana::just(hana::int_c&lt;3&gt;), odd) == hana::just(hana::int_c&lt;3&gt;));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">hana::find_if</a>(hana::just(hana::int_c&lt;2&gt;), odd) == hana::nothing);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">hana::find_if</a>(hana::nothing, odd) == hana::nothing);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga3a168950082f38afd9edf256f336c8ba">hana::all_of</a>(hana::just(hana::int_c&lt;3&gt;), odd));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga3a168950082f38afd9edf256f336c8ba">hana::all_of</a>(hana::nothing, odd));</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="aall__of_8hpp_html"><div class="ttname"><a href="all__of_8hpp.html">all_of.hpp</a></div><div class="ttdoc">Defines boost::hana::all_of.</div></div>
<div class="ttc" id="afind__if_8hpp_html"><div class="ttname"><a href="find__if_8hpp.html">find_if.hpp</a></div><div class="ttdoc">Defines boost::hana::find_if.</div></div>
<div class="ttc" id="agroup__group-_searchable_html_ga3a168950082f38afd9edf256f336c8ba"><div class="ttname"><a href="group__group-_searchable.html#ga3a168950082f38afd9edf256f336c8ba">boost::hana::all_of</a></div><div class="ttdeci">constexpr auto all_of</div><div class="ttdoc">Returns whether all the keys of the structure satisfy the predicate.</div><div class="ttdef"><b>Definition:</b> all_of.hpp:38</div></div>
<div class="ttc" id="agroup__group-_searchable_html_ga7f99b80672aa80a7eb8b223955ce546f"><div class="ttname"><a href="group__group-_searchable.html#ga7f99b80672aa80a7eb8b223955ce546f">boost::hana::find_if</a></div><div class="ttdeci">constexpr auto find_if</div><div class="ttdoc">Finds the value associated to the first key satisfying a predicate.</div><div class="ttdef"><b>Definition:</b> find_if.hpp:41</div></div>
<div class="ttc" id="aintegral__constant_8hpp_html"><div class="ttname"><a href="integral__constant_8hpp.html">integral_constant.hpp</a></div><div class="ttdoc">Defines boost::hana::integral_constant.</div></div>
<div class="ttc" id="amod_8hpp_html"><div class="ttname"><a href="mod_8hpp.html">mod.hpp</a></div><div class="ttdoc">Defines boost::hana::mod.</div></div>
</div><!-- fragment --> </li>
</ol>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="related"></a>
Synopsis of associated functions</h2></td></tr>
<tr class="memitem:a76a84854b3051af000e698157d63a6a8"><td class="memItemLeft" align="right" valign="top">template&lt;&gt; </td></tr>
<tr class="memitem:a76a84854b3051af000e698157d63a6a8"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a76a84854b3051af000e698157d63a6a8">make&lt; optional_tag &gt;</a></td></tr>
<tr class="memdesc:a76a84854b3051af000e698157d63a6a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create an optional value.  <a href="structboost_1_1hana_1_1optional.html#a76a84854b3051af000e698157d63a6a8">More...</a><br /></td></tr>
<tr class="separator:a76a84854b3051af000e698157d63a6a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af1105a435d6435a2437cb5dc162ba463"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#af1105a435d6435a2437cb5dc162ba463">make_optional</a> = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html">optional_tag</a>&gt;</td></tr>
<tr class="memdesc:af1105a435d6435a2437cb5dc162ba463"><td class="mdescLeft">&#160;</td><td class="mdescRight">Alias to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;</code>; provided for convenience.  <a href="structboost_1_1hana_1_1optional.html#af1105a435d6435a2437cb5dc162ba463">More...</a><br /></td></tr>
<tr class="separator:af1105a435d6435a2437cb5dc162ba463"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8ad818d6df7379b0adefa45d2ac844d0"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a></td></tr>
<tr class="memdesc:a8ad818d6df7379b0adefa45d2ac844d0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create an optional value containing <code>x</code>.  <a href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">More...</a><br /></td></tr>
<tr class="separator:a8ad818d6df7379b0adefa45d2ac844d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0c315287473aa87fe5ccd9d8a1c10186"><td class="memItemLeft" align="right" valign="top">constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a> {}</td></tr>
<tr class="memdesc:a0c315287473aa87fe5ccd9d8a1c10186"><td class="mdescLeft">&#160;</td><td class="mdescRight">An empty optional value.  <a href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">More...</a><br /></td></tr>
<tr class="separator:a0c315287473aa87fe5ccd9d8a1c10186"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6529e11cb228e99a05e81071752807d5"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a6529e11cb228e99a05e81071752807d5">maybe</a></td></tr>
<tr class="memdesc:a6529e11cb228e99a05e81071752807d5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Apply a function to the contents of an optional, with a fallback result.  <a href="structboost_1_1hana_1_1optional.html#a6529e11cb228e99a05e81071752807d5">More...</a><br /></td></tr>
<tr class="separator:a6529e11cb228e99a05e81071752807d5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa4c8c0b1ef3d8206974734b93646c9fd"><td class="memItemLeft" align="right" valign="top">auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#aa4c8c0b1ef3d8206974734b93646c9fd">sfinae</a></td></tr>
<tr class="memdesc:aa4c8c0b1ef3d8206974734b93646c9fd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calls a function if the call expression is well-formed.  <a href="structboost_1_1hana_1_1optional.html#aa4c8c0b1ef3d8206974734b93646c9fd">More...</a><br /></td></tr>
<tr class="separator:aa4c8c0b1ef3d8206974734b93646c9fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1047a69893a62cd36eb0d2934f85e0e7"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a1047a69893a62cd36eb0d2934f85e0e7">is_just</a></td></tr>
<tr class="memdesc:a1047a69893a62cd36eb0d2934f85e0e7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return whether an <code>optional</code> contains a value.  <a href="structboost_1_1hana_1_1optional.html#a1047a69893a62cd36eb0d2934f85e0e7">More...</a><br /></td></tr>
<tr class="separator:a1047a69893a62cd36eb0d2934f85e0e7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4eb266d123883c23853f7731a6c5953f"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a4eb266d123883c23853f7731a6c5953f">is_nothing</a></td></tr>
<tr class="memdesc:a4eb266d123883c23853f7731a6c5953f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return whether an <code>optional</code> is empty.  <a href="structboost_1_1hana_1_1optional.html#a4eb266d123883c23853f7731a6c5953f">More...</a><br /></td></tr>
<tr class="separator:a4eb266d123883c23853f7731a6c5953f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:af19873df9190014c0dd09781c210becc"><td class="memTemplParams" colspan="2"><a id="af19873df9190014c0dd09781c210becc"></a>
template&lt;typename ... T, typename F &gt; </td></tr>
<tr class="memitem:af19873df9190014c0dd09781c210becc"><td class="memTemplItemLeft" align="right" valign="top">constexpr friend auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#af19873df9190014c0dd09781c210becc">operator|</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a>&lt; T... &gt;, F)</td></tr>
<tr class="memdesc:af19873df9190014c0dd09781c210becc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code>hana::chain</code>. <br /></td></tr>
<tr class="separator:af19873df9190014c0dd09781c210becc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a22bef1b2c14cf393a3a9cb1924d8c8ff"><td class="memTemplParams" colspan="2"><a id="a22bef1b2c14cf393a3a9cb1924d8c8ff"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:a22bef1b2c14cf393a3a9cb1924d8c8ff"><td class="memTemplItemLeft" align="right" valign="top">constexpr friend auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a22bef1b2c14cf393a3a9cb1924d8c8ff">operator==</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:a22bef1b2c14cf393a3a9cb1924d8c8ff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547" title="Returns a Logical representing whether x is equal to y.">hana::equal</a></code> <br /></td></tr>
<tr class="separator:a22bef1b2c14cf393a3a9cb1924d8c8ff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4ecea0deb4c00ae2eb0b0713ee0645e9"><td class="memTemplParams" colspan="2"><a id="a4ecea0deb4c00ae2eb0b0713ee0645e9"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:a4ecea0deb4c00ae2eb0b0713ee0645e9"><td class="memTemplItemLeft" align="right" valign="top">constexpr friend auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a4ecea0deb4c00ae2eb0b0713ee0645e9">operator!=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:a4ecea0deb4c00ae2eb0b0713ee0645e9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-_comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd" title="Returns a Logical representing whether x is not equal to y.">hana::not_equal</a></code> <br /></td></tr>
<tr class="separator:a4ecea0deb4c00ae2eb0b0713ee0645e9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aca31ad50b2d35d48aac88aa762530c75"><td class="memTemplParams" colspan="2"><a id="aca31ad50b2d35d48aac88aa762530c75"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:aca31ad50b2d35d48aac88aa762530c75"><td class="memTemplItemLeft" align="right" valign="top">constexpr friend auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#aca31ad50b2d35d48aac88aa762530c75">operator&lt;</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:aca31ad50b2d35d48aac88aa762530c75"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-_orderable.html#gad510011602bdb14686f1c4ec145301c9" title="Returns a Logical representing whether x is less than y.">hana::less</a></code> <br /></td></tr>
<tr class="separator:aca31ad50b2d35d48aac88aa762530c75"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a65b9400772e651101ae83d7f9f7ba84d"><td class="memTemplParams" colspan="2"><a id="a65b9400772e651101ae83d7f9f7ba84d"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:a65b9400772e651101ae83d7f9f7ba84d"><td class="memTemplItemLeft" align="right" valign="top">constexpr friend auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a65b9400772e651101ae83d7f9f7ba84d">operator&gt;</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:a65b9400772e651101ae83d7f9f7ba84d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-_orderable.html#gaf9a073eafebbe514fb19dff82318f198" title="Returns a Logical representing whether x is greater than y.">hana::greater</a></code> <br /></td></tr>
<tr class="separator:a65b9400772e651101ae83d7f9f7ba84d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a971bac762b767fe0ec222adb367c9aeb"><td class="memTemplParams" colspan="2"><a id="a971bac762b767fe0ec222adb367c9aeb"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:a971bac762b767fe0ec222adb367c9aeb"><td class="memTemplItemLeft" align="right" valign="top">constexpr friend auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a971bac762b767fe0ec222adb367c9aeb">operator&lt;=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:a971bac762b767fe0ec222adb367c9aeb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-_orderable.html#ga9917dd82beb67151bf5657245d37b851" title="Returns a Logical representing whether x is less than or equal to y.">hana::less_equal</a></code> <br /></td></tr>
<tr class="separator:a971bac762b767fe0ec222adb367c9aeb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adec95a8109b858673412671ba341611b"><td class="memTemplParams" colspan="2"><a id="adec95a8109b858673412671ba341611b"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:adec95a8109b858673412671ba341611b"><td class="memTemplItemLeft" align="right" valign="top">constexpr friend auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#adec95a8109b858673412671ba341611b">operator&gt;=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:adec95a8109b858673412671ba341611b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-_orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703" title="Returns a Logical representing whether x is greater than or equal to y.">hana::greater_equal</a></code> <br /></td></tr>
<tr class="separator:adec95a8109b858673412671ba341611b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aefbd278cf7bb9e921707d6d827014bcb"><td class="memItemLeft" align="right" valign="top"><a id="aefbd278cf7bb9e921707d6d827014bcb"></a>
constexpr&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#aefbd278cf7bb9e921707d6d827014bcb">optional</a> ()=default</td></tr>
<tr class="memdesc:aefbd278cf7bb9e921707d6d827014bcb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default-construct an <code>optional</code>. Only exists if the optional contains a value, and if that value is DefaultConstructible. <br /></td></tr>
<tr class="separator:aefbd278cf7bb9e921707d6d827014bcb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9074406adb54a6a848ba482895c51d1f"><td class="memItemLeft" align="right" valign="top"><a id="a9074406adb54a6a848ba482895c51d1f"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a9074406adb54a6a848ba482895c51d1f">optional</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> const &amp;)=default</td></tr>
<tr class="memdesc:a9074406adb54a6a848ba482895c51d1f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy-construct an <code>optional</code>. An empty optional may only be copy-constructed from another empty <code>optional</code>, and an <code>optional</code> with a value may only be copy-constructed from another <code>optional</code> with a value. Furthermore, this constructor only exists if the value held in the <code>optional</code> is CopyConstructible. <br /></td></tr>
<tr class="separator:a9074406adb54a6a848ba482895c51d1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac46a23f0ada20175c4c9a58af3d15753"><td class="memItemLeft" align="right" valign="top"><a id="ac46a23f0ada20175c4c9a58af3d15753"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#ac46a23f0ada20175c4c9a58af3d15753">optional</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&amp;)=default</td></tr>
<tr class="memdesc:ac46a23f0ada20175c4c9a58af3d15753"><td class="mdescLeft">&#160;</td><td class="mdescRight">Move-construct an <code>optional</code>. An empty optional may only be move-constructed from another empty <code>optional</code>, and an <code>optional</code> with a value may only be move-constructed from another <code>optional</code> with a value. Furthermore, this constructor only exists if the value held in the <code>optional</code> is MoveConstructible. <br /></td></tr>
<tr class="separator:ac46a23f0ada20175c4c9a58af3d15753"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2b04ee87c0ac58621edf3ad5476a2949"><td class="memItemLeft" align="right" valign="top"><a id="a2b04ee87c0ac58621edf3ad5476a2949"></a>
constexpr&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a2b04ee87c0ac58621edf3ad5476a2949">optional</a> (T const &amp;t)</td></tr>
<tr class="memdesc:a2b04ee87c0ac58621edf3ad5476a2949"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct an <code>optional</code> holding a value of type <code>T</code> from another object of type <code>T</code>. The value is copy-constructed. <br /></td></tr>
<tr class="separator:a2b04ee87c0ac58621edf3ad5476a2949"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf824827b5d6f8c87d23b9526b9f35d2"><td class="memItemLeft" align="right" valign="top"><a id="adf824827b5d6f8c87d23b9526b9f35d2"></a>
constexpr&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#adf824827b5d6f8c87d23b9526b9f35d2">optional</a> (T &amp;&amp;t)</td></tr>
<tr class="memdesc:adf824827b5d6f8c87d23b9526b9f35d2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct an <code>optional</code> holding a value of type <code>T</code> from another object of type <code>T</code>. The value is move-constructed. <br /></td></tr>
<tr class="separator:adf824827b5d6f8c87d23b9526b9f35d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abefc885243f38c66c52fdada3588f951"><td class="memItemLeft" align="right" valign="top"><a id="abefc885243f38c66c52fdada3588f951"></a>
constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#abefc885243f38c66c52fdada3588f951">operator=</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> const &amp;)=default</td></tr>
<tr class="memdesc:abefc885243f38c66c52fdada3588f951"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy-assign an <code>optional</code>. An empty optional may only be copy-assigned from another empty <code>optional</code>, and an <code>optional</code> with a value may only be copy-assigned from another <code>optional</code> with a value. Furthermore, this assignment operator only exists if the value held in the <code>optional</code> is CopyAssignable. <br /></td></tr>
<tr class="separator:abefc885243f38c66c52fdada3588f951"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a52057c5da4b9aee49ee15a167459fc9a"><td class="memItemLeft" align="right" valign="top"><a id="a52057c5da4b9aee49ee15a167459fc9a"></a>
constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a52057c5da4b9aee49ee15a167459fc9a">operator=</a> (<a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> &amp;&amp;)=default</td></tr>
<tr class="memdesc:a52057c5da4b9aee49ee15a167459fc9a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Move-assign an <code>optional</code>. An empty optional may only be move-assigned from another empty <code>optional</code>, and an <code>optional</code> with a value may only be move-assigned from another <code>optional</code> with a value. Furthermore, this assignment operator only exists if the value held in the <code>optional</code> is MoveAssignable. <br /></td></tr>
<tr class="separator:a52057c5da4b9aee49ee15a167459fc9a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6eeef1512294d408857805eb3a790230"><td class="memItemLeft" align="right" valign="top">constexpr T *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a6eeef1512294d408857805eb3a790230">operator-&gt;</a> ()</td></tr>
<tr class="memdesc:a6eeef1512294d408857805eb3a790230"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a pointer to the contained value, or a <code>nullptr</code> if the <code>optional</code> is empty.  <a href="structboost_1_1hana_1_1optional.html#a6eeef1512294d408857805eb3a790230">More...</a><br /></td></tr>
<tr class="separator:a6eeef1512294d408857805eb3a790230"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acdcf71b43d4e27d5efbf0ad875d0be58"><td class="memItemLeft" align="right" valign="top">constexpr T &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a> ()</td></tr>
<tr class="memdesc:acdcf71b43d4e27d5efbf0ad875d0be58"><td class="mdescLeft">&#160;</td><td class="mdescRight">Extract the content of an <code>optional</code>, or fail at compile-time.  <a href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">More...</a><br /></td></tr>
<tr class="separator:acdcf71b43d4e27d5efbf0ad875d0be58"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3132b919ab7710d79155674272961d4b"><td class="memItemLeft" align="right" valign="top">constexpr T &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#a3132b919ab7710d79155674272961d4b">operator*</a> ()</td></tr>
<tr class="memdesc:a3132b919ab7710d79155674272961d4b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58" title="Extract the content of an optional, or fail at compile-time.">value()</a></code>, provided for convenience.  <a href="structboost_1_1hana_1_1optional.html#a3132b919ab7710d79155674272961d4b">More...</a><br /></td></tr>
<tr class="separator:a3132b919ab7710d79155674272961d4b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab65fe691bafd979111b52f97ec258e48"><td class="memTemplParams" colspan="2">template&lt;typename U &gt; </td></tr>
<tr class="memitem:ab65fe691bafd979111b52f97ec258e48"><td class="memTemplItemLeft" align="right" valign="top">constexpr decltype(auto)&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1optional.html#ab65fe691bafd979111b52f97ec258e48">value_or</a> (U &amp;&amp;<a class="el" href="structboost_1_1hana_1_1default__.html">default_</a>)</td></tr>
<tr class="memdesc:ab65fe691bafd979111b52f97ec258e48"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the contents of an <code>optional</code>, with a fallback result.  <a href="structboost_1_1hana_1_1optional.html#ab65fe691bafd979111b52f97ec258e48">More...</a><br /></td></tr>
<tr class="separator:ab65fe691bafd979111b52f97ec258e48"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Associated functions</h2>
<a id="a76a84854b3051af000e698157d63a6a8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a76a84854b3051af000e698157d63a6a8">&#9670;&nbsp;</a></span>make&lt; optional_tag &gt;</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<div class="memtemplate">
template&lt;&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt; <a class="el" href="structboost_1_1hana_1_1optional__tag.html">optional_tag</a> &gt;</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= []([<span class="keyword">auto</span>&amp;&amp; x]) {</div>
<div class="line">        <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#aefbd278cf7bb9e921707d6d827014bcb">optional</a>&lt;std::decay&lt;decltype(x)&gt;::type&gt;{forwarded(x)};</div>
<div class="line">    }</div>
<div class="ttc" id="astructboost_1_1hana_1_1optional_html_aefbd278cf7bb9e921707d6d827014bcb"><div class="ttname"><a href="structboost_1_1hana_1_1optional.html#aefbd278cf7bb9e921707d6d827014bcb">boost::hana::optional::optional</a></div><div class="ttdeci">constexpr optional()=default</div><div class="ttdoc">Default-construct an optional. Only exists if the optional contains a value, and if that value is Def...</div></div>
</div><!-- fragment -->
<p>Create an optional value. </p>
<p>Specifically, <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;()</code> is equivalent to <code>nothing</code>, and <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;(x)</code> is equivalent to <code>just(x)</code>. This is provided for consistency with the other <code>make&lt;...&gt;</code> functions.</p>
<h2><a class="anchor" id="autotoc_md297"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2make_8hpp.html">boost/hana/core/make.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    constexpr <span class="keyword">auto</span> x = hana::make&lt;hana::optional_tag&gt;();</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(x == hana::make_optional());</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_nothing(x));</div>
<div class="line"> </div>
<div class="line">    constexpr <span class="keyword">auto</span> just_x = hana::make&lt;hana::optional_tag&gt;(<span class="charliteral">&#39;x&#39;</span>);</div>
<div class="line">    static_assert(just_x == hana::make_optional(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_just(just_x));</div>
<div class="line">}</div>
<div class="ttc" id="acore_2make_8hpp_html"><div class="ttname"><a href="core_2make_8hpp.html">make.hpp</a></div><div class="ttdoc">Defines boost::hana::make.</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="af1105a435d6435a2437cb5dc162ba463"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af1105a435d6435a2437cb5dc162ba463">&#9670;&nbsp;</a></span>make_optional</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto make_optional = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html">optional_tag</a>&gt;</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Alias to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1optional__tag.html" title="Tag representing a hana::optional.">optional_tag</a>&gt;</code>; provided for convenience. </p>
<h2><a class="anchor" id="autotoc_md298"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2make_8hpp.html">boost/hana/core/make.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    constexpr <span class="keyword">auto</span> x = hana::make&lt;hana::optional_tag&gt;();</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(x == hana::make_optional());</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_nothing(x));</div>
<div class="line"> </div>
<div class="line">    constexpr <span class="keyword">auto</span> just_x = hana::make&lt;hana::optional_tag&gt;(<span class="charliteral">&#39;x&#39;</span>);</div>
<div class="line">    static_assert(just_x == hana::make_optional(<span class="charliteral">&#39;x&#39;</span>), <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_just(just_x));</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a8ad818d6df7379b0adefa45d2ac844d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8ad818d6df7379b0adefa45d2ac844d0">&#9670;&nbsp;</a></span>just</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto just</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) {</div>
<div class="line">        <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#aefbd278cf7bb9e921707d6d827014bcb">optional</a>&lt;std::decay&lt;decltype(x)&gt;::type&gt;{forwarded(x)};</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Create an optional value containing <code>x</code>. </p>
<h2><a class="anchor" id="autotoc_md299"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">constexpr <span class="keyword">auto</span> just_x = hana::just(<span class="charliteral">&#39;x&#39;</span>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_just(just_x));</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a0c315287473aa87fe5ccd9d8a1c10186"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0c315287473aa87fe5ccd9d8a1c10186">&#9670;&nbsp;</a></span>nothing</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr <a class="el" href="structboost_1_1hana_1_1optional.html">optional</a> nothing {}</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>An empty optional value. </p>
<h2><a class="anchor" id="autotoc_md300"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">constexpr <span class="keyword">auto</span> x = hana::nothing;</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::is_nothing(x));</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a6529e11cb228e99a05e81071752807d5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6529e11cb228e99a05e81071752807d5">&#9670;&nbsp;</a></span>maybe</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto maybe</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; default_, <span class="keyword">auto</span>&amp;&amp; f, <span class="keyword">auto</span>&amp;&amp; m) -&gt; decltype(<span class="keyword">auto</span>) {</div>
<div class="line">        <span class="keywordflow">if</span> (m is a <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x)) {</div>
<div class="line">            <span class="keywordflow">return</span> forwarded(f)(forwarded(x));</div>
<div class="line">        <span class="keywordflow">else</span></div>
<div class="line">            <span class="keywordflow">return</span> forwarded(default_);</div>
<div class="line">        }</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Apply a function to the contents of an optional, with a fallback result. </p>
<p>Specifically, <code>maybe</code> takes a default value, a function and an optional value. If the optional value is <code>nothing</code>, the default value is returned. Otherwise, the function is applied to the content of the <code>just</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname"><a class="el" href="structboost_1_1hana_1_1default__.html" title="Mark a tag-dispatched method implementation as a default implementation.">default_</a></td><td>A default value returned if <code>m</code> is <code>nothing</code>.</td></tr>
    <tr><td class="paramname">f</td><td>A function called as <code>f(x)</code> if and only if <code>m</code> is an optional value of the form <code>just(x)</code>. In that case, the result returend by <code>maybe</code> is the result of <code>f</code>.</td></tr>
    <tr><td class="paramname">m</td><td>An optional value.</td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="autotoc_md301"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="placeholder_8hpp.html">boost/hana/functional/placeholder.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">static_assert(hana::maybe(<span class="charliteral">&#39;x&#39;</span>, <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1, hana::just(1)) == 2, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">static_assert(hana::maybe(<span class="charliteral">&#39;x&#39;</span>, <a class="code" href="group__group-functional.html#gaefe9fd152cba94be71c2b5b9de689d23">hana::_</a> + 1, hana::nothing) == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
<a id="aa4c8c0b1ef3d8206974734b93646c9fd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa4c8c0b1ef3d8206974734b93646c9fd">&#9670;&nbsp;</a></span>sfinae</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">auto sfinae</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; f) {</div>
<div class="line">        <span class="keywordflow">return</span> [perfect-<a class="code" href="group__group-functional.html#ga41ada6b336e9d5bcb101ff0c737acbd0">capture</a>](<span class="keyword">auto</span>&amp;&amp; ...x) {</div>
<div class="line">            <span class="keywordflow">if</span> (decltype(forwarded(f)(forwarded(x)...)) is well-formed)</div>
<div class="line">                <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(forwarded(f)(forwarded(x)...));</div>
<div class="line">            <span class="keywordflow">else</span></div>
<div class="line">                <span class="keywordflow">return</span> <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>;</div>
<div class="line">        };</div>
<div class="line">    }</div>
<div class="ttc" id="agroup__group-functional_html_ga41ada6b336e9d5bcb101ff0c737acbd0"><div class="ttname"><a href="group__group-functional.html#ga41ada6b336e9d5bcb101ff0c737acbd0">boost::hana::capture</a></div><div class="ttdeci">constexpr auto capture</div><div class="ttdoc">Create a function capturing the given variables.</div><div class="ttdef"><b>Definition:</b> capture.hpp:45</div></div>
</div><!-- fragment -->
<p>Calls a function if the call expression is well-formed. </p>
<p>Given a function <code>f</code>, <code>sfinae</code> returns a new function applying <code>f</code> to its arguments and returning <code>just</code> the result if the call is well-formed, and <code>nothing</code> otherwise. In other words, <code>sfinae(f)(x...)</code> is <code>just(f(x...))</code> if that expression is well-formed, and <code>nothing</code> otherwise. Note, however, that it is possible for an expression <code>f(x...)</code> to be well-formed as far as SFINAE is concerned, but trying to actually compile <code>f(x...)</code> still fails. In this case, <code>sfinae</code> won't be able to detect it and a hard failure is likely to happen.</p>
<dl class="section note"><dt>Note</dt><dd>The function given to <code>sfinae</code> must not return <code>void</code>, since <code><a class="el" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0" title="Create an optional value containing x.">just(void)</a></code> does not make sense. A compilation error is triggered if the function returns void.</dd></dl>
<h2><a class="anchor" id="autotoc_md302"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="config_8hpp.html">boost/hana/config.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> incr = [](<span class="keyword">auto</span> x) -&gt; decltype(x + 1) {</div>
<div class="line">        <span class="keywordflow">return</span> x + 1;</div>
<div class="line">    };</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(hana::sfinae(incr)(1) == hana::just(2));</div>
<div class="line"> </div>
<div class="line">    <span class="keyword">struct </span>invalid { };</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(hana::sfinae(incr)(invalid{}) == hana::nothing);</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a1047a69893a62cd36eb0d2934f85e0e7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1047a69893a62cd36eb0d2934f85e0e7">&#9670;&nbsp;</a></span>is_just</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto is_just</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span> <span class="keyword">const</span>&amp; m) {</div>
<div class="line">        <span class="keywordflow">return</span> m is a <a class="code" href="structboost_1_1hana_1_1optional.html#a8ad818d6df7379b0adefa45d2ac844d0">just</a>(x);</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Return whether an <code>optional</code> contains a value. </p>
<p>Specifically, returns a compile-time true-valued <code>Logical</code> if <code>m</code> is of the form <code>just(x)</code> for some <code>x</code>, and a false-valued one otherwise.</p>
<h2><a class="anchor" id="autotoc_md303"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>( hana::is_just(hana::just(<span class="charliteral">&#39;x&#39;</span>)));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>( hana::is_just(hana::just(hana::nothing)));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(!hana::is_just(hana::nothing));</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a4eb266d123883c23853f7731a6c5953f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4eb266d123883c23853f7731a6c5953f">&#9670;&nbsp;</a></span>is_nothing</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto is_nothing</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span> <span class="keyword">const</span>&amp; m) {</div>
<div class="line">        <span class="keywordflow">return</span> m is a <a class="code" href="structboost_1_1hana_1_1optional.html#a0c315287473aa87fe5ccd9d8a1c10186">nothing</a>;</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Return whether an <code>optional</code> is empty. </p>
<p>Specifically, returns a compile-time true-valued <code>Logical</code> if <code>m</code> is a <code>nothing</code>, and a false-valued one otherwise.</p>
<h2><a class="anchor" id="autotoc_md304"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>( hana::is_nothing(hana::nothing));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(!hana::is_nothing(hana::just(<span class="charliteral">&#39;x&#39;</span>)));</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(!hana::is_nothing(hana::just(hana::nothing)));</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
</div><!-- fragment --> 
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a6eeef1512294d408857805eb3a790230"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6eeef1512294d408857805eb3a790230">&#9670;&nbsp;</a></span>operator-&gt;()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr T* <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::operator-&gt; </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns a pointer to the contained value, or a <code>nullptr</code> if the <code>optional</code> is empty. </p>
<dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for both the <code>const</code> and the non-<code>const</code> cases.</dd></dl>
<h2><a class="anchor" id="autotoc_md305"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>).<a class="code" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a>() == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(*hana::just(hana::type_c&lt;int&gt;) == hana::type_c&lt;int&gt;);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::just(std::string{<span class="stringliteral">&quot;abcd&quot;</span>})-&gt;<a class="code" href="group__group-_foldable.html#ga8ec3ac9a6f5014db943f61ebc9e1e36e">size</a>() == 4);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// hana::nothing.value(); // compile-time error</span></div>
<div class="line">}</div>
<div class="ttc" id="agroup__group-_foldable_html_ga8ec3ac9a6f5014db943f61ebc9e1e36e"><div class="ttname"><a href="group__group-_foldable.html#ga8ec3ac9a6f5014db943f61ebc9e1e36e">boost::hana::size</a></div><div class="ttdeci">constexpr auto size</div><div class="ttdoc">Equivalent to length; provided for consistency with the standard library.</div><div class="ttdef"><b>Definition:</b> size.hpp:30</div></div>
<div class="ttc" id="agroup__group-assertions_html_ga4796ae107d58b67e0bbccd5ae6f70101"><div class="ttname"><a href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_RUNTIME_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_RUNTIME_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTIO...</div><div class="ttdef"><b>Definition:</b> assert.hpp:209</div></div>
<div class="ttc" id="astructboost_1_1hana_1_1optional_html_acdcf71b43d4e27d5efbf0ad875d0be58"><div class="ttname"><a href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">boost::hana::optional::value</a></div><div class="ttdeci">constexpr T &amp; value()</div><div class="ttdoc">Extract the content of an optional, or fail at compile-time.</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="acdcf71b43d4e27d5efbf0ad875d0be58"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acdcf71b43d4e27d5efbf0ad875d0be58">&#9670;&nbsp;</a></span>value()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr T&amp; <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::value </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Extract the content of an <code>optional</code>, or fail at compile-time. </p>
<p>If <code>*this</code> contains a value, that value is returned. Otherwise, a static assertion is triggered.</p>
<dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for the cases where <code>*this</code> is a reference, a rvalue-reference and their <code>const</code> counterparts.</dd></dl>
<h2><a class="anchor" id="autotoc_md306"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>).<a class="code" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a>() == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(*hana::just(hana::type_c&lt;int&gt;) == hana::type_c&lt;int&gt;);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::just(std::string{<span class="stringliteral">&quot;abcd&quot;</span>})-&gt;<a class="code" href="group__group-_foldable.html#ga8ec3ac9a6f5014db943f61ebc9e1e36e">size</a>() == 4);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// hana::nothing.value(); // compile-time error</span></div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a3132b919ab7710d79155674272961d4b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3132b919ab7710d79155674272961d4b">&#9670;&nbsp;</a></span>operator*()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr T&amp; <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::operator* </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Equivalent to <code><a class="el" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58" title="Extract the content of an optional, or fail at compile-time.">value()</a></code>, provided for convenience. </p>
<dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for the cases where <code>*this</code> is a reference, a rvalue-reference and their <code>const</code> counterparts.</dd></dl>
<h2><a class="anchor" id="autotoc_md307"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    static_assert(hana::just(<span class="charliteral">&#39;x&#39;</span>).<a class="code" href="structboost_1_1hana_1_1optional.html#acdcf71b43d4e27d5efbf0ad875d0be58">value</a>() == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(*hana::just(hana::type_c&lt;int&gt;) == hana::type_c&lt;int&gt;);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::just(std::string{<span class="stringliteral">&quot;abcd&quot;</span>})-&gt;<a class="code" href="group__group-_foldable.html#ga8ec3ac9a6f5014db943f61ebc9e1e36e">size</a>() == 4);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// hana::nothing.value(); // compile-time error</span></div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a id="ab65fe691bafd979111b52f97ec258e48"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab65fe691bafd979111b52f97ec258e48">&#9670;&nbsp;</a></span>value_or()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename ... T&gt; </div>
<div class="memtemplate">
template&lt;typename U &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr decltype(auto) <a class="el" href="structboost_1_1hana_1_1optional.html">boost::hana::optional</a>&lt; T &gt;::value_or </td>
          <td>(</td>
          <td class="paramtype">U &amp;&amp;&#160;</td>
          <td class="paramname"><em>default_</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the contents of an <code>optional</code>, with a fallback result. </p>
<p>If <code>*this</code> contains a value, that value is returned. Otherwise, the default value provided is returned.</p>
<dl class="section note"><dt>Note</dt><dd>Overloads of this method are provided for the cases where <code>*this</code> is a reference, a rvalue-reference and their <code>const</code> counterparts.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname"><a class="el" href="structboost_1_1hana_1_1default__.html" title="Mark a tag-dispatched method implementation as a default implementation.">default_</a></td><td>The default value to return if <code>*this</code> does not contain a value.</td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="autotoc_md308"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">static_assert(hana::just(1).<a class="code" href="structboost_1_1hana_1_1optional.html#ab65fe691bafd979111b52f97ec258e48">value_or</a>(<span class="charliteral">&#39;x&#39;</span>) == 1, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line">static_assert(hana::nothing.<a class="code" href="structboost_1_1hana_1_1optional.html#ab65fe691bafd979111b52f97ec258e48">value_or</a>(<span class="charliteral">&#39;x&#39;</span>) == <span class="charliteral">&#39;x&#39;</span>, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() { }</div>
<div class="ttc" id="astructboost_1_1hana_1_1optional_html_ab65fe691bafd979111b52f97ec258e48"><div class="ttname"><a href="structboost_1_1hana_1_1optional.html#ab65fe691bafd979111b52f97ec258e48">boost::hana::optional::value_or</a></div><div class="ttdeci">constexpr decltype(auto) value_or(U &amp;&amp;default_)</div><div class="ttdoc">Return the contents of an optional, with a fallback result.</div></div>
</div><!-- fragment --> 
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>boost</b></li><li class="navelem"><a class="el" href="namespaceboost_1_1hana.html">hana</a></li><li class="navelem"><a class="el" href="structboost_1_1hana_1_1optional.html">optional</a></li>
  </ul>
</div>
</body>
</html>
